package com.example.flutternative;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.view.FlutterMain;

/*
 * Create by weslywang on 2020/3/12
 * Copyright © 2020 Tencent
 *
 * Description:
 */
public class FlutterDemo extends FlutterActivity {
    //跳转该页面的时候可以传要跳转的页面,参数名固定为route
    private static final String ROUTE_PAGE = "route";

    public static Intent makeIntent(Context context, String routePage) {
        if (routePage == null || routePage.equals("")) {
            routePage = "/";
        }
        Intent intent = new Intent(context, FlutterDemo.class);
        intent.setAction(Intent.ACTION_RUN);
        intent.putExtra(ROUTE_PAGE, routePage);
        return intent;
    }

    public void onCreate(@Nullable Bundle savedInstanceState) {
        //或者在这里初始化Flutter
        FlutterMain.startInitialization(this);
        super.onCreate(savedInstanceState);
//        GeneratedPluginRegistrant.registerWith(this);
    }
}
